package com.google.code.tretris.network.filter;

import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;

import com.google.code.tretris.network.events.TretrisMessage;

public class TretrisPacketFilter implements PacketFilter {

	public boolean accept(Packet packet) {
		boolean acceptPacket = false;
		
		
		if (packet instanceof Message) {
			
			if(((Message)packet).getBody().indexOf(TretrisMessage.CONTROLL_EVENT)!= -1 ||
					((Message)packet).getBody().indexOf(TretrisMessage.MOVE_EVENT)!=-1 ||
					((Message)packet).getBody().indexOf(TretrisMessage.ROTATE_EVENT)!=-1 ||
					((Message)packet).getBody().indexOf(TretrisMessage.UPDATEBOARD_EVENT)!=-1){
				acceptPacket = true;
			}
		} 

		return acceptPacket;
	}
}
